package thread;

/**
 * Creared with IntelliJ IDEA.
 * Description:
 * User:yxd
 * Date:2022-03-20
 * Time:23:46
 */
public class Demo8 {
    public static void main(String[] args) {
        Thread t = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.interrupted());
            }
        });
        t.start();
        t.interrupt();//使用者线程中断会清楚标记位
        Thread t2 = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().isInterrupted());
            }
        });
        t2.start();
        t2.interrupt();//使用Thread.currentThread().isInterrupted()这个标记位不会被清空
    }
}
